# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Vojtěch Aschenbrenner <v@asch.cz>

_gemname=trollop
pkgname=ruby-${_gemname}
pkgver=2.9.10
pkgrel=1
pkgdesc='Commandline option parser for Ruby that just gets out of your way'
url='http://manageiq.github.io/trollop/'
arch=('any')
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc')
options=('!emptydirs')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/ManageIQ/trollop/archive/v${pkgver}.tar.gz)
sha512sums=('5219ed055440182a89a591c826fd36f721183594d9130e8a77c75ebd30b981bfccf7a5f40a5815e77b13b3840cd61eafceaf54577fa4198d7fce8a49bd2c42ad')

prepare() {
  cd optimist-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec # don't give a fuck about rubys bla bla
  sed 's|git ls-files -z|find -type f -print0\|sed "s,\\\\./,,g"|' -i ${_gemname}.gemspec
}

build() {
  cd optimist-${pkgver}
  gem build ${_gemname}.gemspec
}

package() {
  cd optimist-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/README.md" -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 "${pkgdir}${_gemdir}/gems/${_gemname}-${pkgver}/README.md" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  rm "${pkgdir}/${_gemdir}/cache/${_gemname}-${pkgver}.gem"
}

# vim: ts=2 sw=2 et:
